<?php

$username = $_POST["username"];
$password = $_POST["password"];
echo "该用户 $username 已经登陆，"."    "."密码为 $password"."<br>"; 


// 
session_start();

if(isset($_POST["username"]) && isset($_POST["password"])){
    $username = $_POST["username"];
    $password = $_POST["password"];

    if(strlen(trim($username)) > 0 && strlen(trim($password)) > 6 && !isset($_SESSION["username"])){
        $_SESSION["usrname"] = $username;
        echo "<h1>欢迎</h1>"."$username"."登陆成功"."<br>";
    }else if(strlen(trim($username)) > 0 && strlen(trim($password)) > 6 && $_SESSION["username"]){
        
        echo "$username"."您已经登陆过，无需重复登陆！"."<br>";
        unset($_SESSION["usrname"]);
    }else{
        echo "<h1>登陆失败，用户名不符合规范！</h1>"."<br>";
    }
}else{
    echo "<h1>参数错误，已被服务器记录在案！</h1>"."<br>";
}